package com.beforejava5;

/**
 * @Description TODO
 * @Author zhouhai
 * @Date2018/9/617:35
 **/
public class demo2 {
    public static void main(String[] args) throws  InterruptedException {
        CompletableRunnable runnable = new CompletableRunnable();
        Thread t = new Thread(runnable, "sub");

        t.start();

        System.out.printf("[Thread : %s]Starting ... \n",Thread.currentThread().getName());
        System.out.printf("runnable is completed : %s\n",runnable.isCompleted());
    }

    private static class CompletableRunnable implements Runnable{
        private volatile boolean completed;

        @Override
        public void run() {
            completed = true;
            System.out.printf("[Thread : %s]Hello,World ... \n",Thread.currentThread().getName());
        }

        public boolean isCompleted() {
            return completed;
        }
    }

}
